package com.atldy.cloudgrains.exception;


import com.atldy.common.enums.StatusCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.atldy.common.enums.StatusCodeEnum.FAIL;

/**
 * @version 1.0
 * @Author: li-dong-yang
 * @CreateTime: 2021-09-15 16:43
 * @Description： 自定义业务异常
 */
@Getter
@AllArgsConstructor
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private Integer code = FAIL.getCode();

    /**
     * 错误信息
     */
    private final String message;

    public BusinessException(String message) {
        this.message = message;
    }

    public BusinessException(StatusCodeEnum statusCodeEnum) {
        this.code = statusCodeEnum.getCode();
        this.message = statusCodeEnum.getDesc();
    }

}